import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import { RootStackParamList } from './types';
import { MainTabParamList } from './types';


// 导入页面组件
import HomeScreen from '../screens/Home/index';
import StudyScreen from '../screens/Study/index';
import MessageScreen from '../screens/Message/index';

import ProfileScreen from '../screens/Profile/index';
import EditScreen from '../screens/Profile/Edit'; // 导入Edit组件
import IndividualScreen from '../screens/Profile/Individual'; // 导入Individual组件

import LoginScreen from '../screens/Login/index';
import WritingScreen from '../screens/Writing/index';
import ZTsearchScreen from '../screens/Message/components/ZTsearch';
import ChatRoom from '../screens/Message/components/ChatRoom';
import PptGenerationScreen from '../screens/PptGeneration/index';
import SearchScreen from '../screens/Search/index';
import AIWritingScreen from '../screens/AIWriting/index';
import SearcherScreen from '../screens/Searcher/index';
import AITextGenerationScreen from '../screens/AITextGeneration';
import AITextHistoryScreen from '../screens/AITextGeneration/AITextHistory';
import AITextResultScreen from '../screens/AITextGeneration/AITextResult';
import AIImageGenerationScreen from '../screens/AIImageGeneration';
import CourseReportScreen from '../screens/CourseReport';
import ActivityPlanningScreen from '../screens/ActivityPlanning';

const Tab = createBottomTabNavigator<MainTabParamList>();
const Stack = createNativeStackNavigator<RootStackParamList>();

function MainTabs() {
  return (
    <Tab.Navigator
        screenOptions={{
          headerShown: false,
          tabBarActiveTintColor: '#4A90E2',
          tabBarInactiveTintColor: '#8E8E93',
          tabBarStyle: {
            backgroundColor: '#FFFFFF',
            borderTopWidth: 0.5,
            borderTopColor: '#E6F0FA',
          },
        }}
      >
        <Tab.Screen
          name="Home"
          component={HomeScreen}
          options={{
            title: '首页',
            tabBarIcon: ({ color, size }) => (
              <MaterialIcons name="home" color={color} size={size} />
            ),
          }}
        />
        <Tab.Screen
          name="Study"
          component={StudyScreen}
          options={{
            title: '资料库',
            tabBarIcon: ({ color, size }) => (
              <MaterialIcons name="library-books" color={color} size={size} />
            ),
          }}
        />
        <Tab.Screen
          name="Message"
          component={MessageScreen}
          options={{
            title: '消息',
            tabBarIcon: ({ color, size }) => (
              <MaterialIcons name="message" color={color} size={size} />
            ),
          }}
        />
        <Tab.Screen
          name="Writing"
          component={WritingScreen}
          options={{
            title: '光速写作',
            tabBarIcon: ({ color, size }) => (
              <MaterialIcons name="edit" color={color} size={size} />
            ),
          }}
        />
        <Tab.Screen
          name="Profile"
          component={ProfileScreen}
          options={{
            title: '我的',
            tabBarIcon: ({ color, size }) => (
              <MaterialIcons name="person" color={color} size={size} />
            ),
          }}
        />

      </Tab.Navigator>
  );
}

export default function Navigation() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login" screenOptions={{ headerShown: false }}>
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="MainTabs" component={MainTabs} />
        <Stack.Screen name="ZTsearch" component={ZTsearchScreen}/>
        <Stack.Screen name="Chat" component={ChatRoom} options={{ headerShown: true }}/>
        <Stack.Screen name="PptGeneration" component={PptGenerationScreen} />
        <Stack.Screen name="Search" component={SearchScreen} />
        <Stack.Screen name="Study" component={StudyScreen} />
        <Stack.Screen name="AIWriting" component={AIWritingScreen} />
        <Stack.Screen name="Searcher" component={SearcherScreen} />
        <Stack.Screen name="AITextGeneration" component={AITextGenerationScreen} />
        <Stack.Screen name="AITextHistory" component={AITextHistoryScreen} />
        <Stack.Screen name="AITextResult" component={AITextResultScreen} />
        <Stack.Screen name="AIImageGeneration" component={AIImageGenerationScreen} />
        <Stack.Screen name="CourseReport" component={CourseReportScreen} />
        <Stack.Screen name="ActivityPlanning" component={ActivityPlanningScreen} />
        <Stack.Screen name="Edit" component={EditScreen} />
        <Stack.Screen name="Individual" component={IndividualScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}